import cv2
import numpy as np
def mouse_callback(event, x, y, flags, userdata):
    print(event, x, y, flags, userdata)
# 创建窗口
cv2.namedWindow('mouse', cv2.WINDOW_NORMAL)
# 设置窗口大小
cv2.resizeWindow('mouse', 640, 480)
# 设置鼠标回调函数
cv2.setMouseCallback('mouse', mouse_callback,'123')
img = np.zeros((360, 640, 3), np.uint8)
while True:
    cv2.imshow('mouse', img)
    key = cv2.waitKey(1)
    if key & 0xFF == ord('q'):
        break
cv2.destroyWindow('mouse')
